<template>
	<view>
		<view class="top">
			<view class="nav-tab_top">
				<view 
					class="li_top" 
					v-for="(item, index) in tabs_top" 
					:key="index" 
					:class="currentTab_top==index?'current_top':''"
					@click="onTab_topClick(index)"
				>
					<text>{{item.title}} {{item.count}}</text>
				</view>
			</view>
		</view>
		
		<view class="nav-tab">
			<view 
				class="li" 
				v-for="(item, index) in tabs" 
				:key="index" 
				:class="currentTab==index?'current':''"
				@click="onTabClick(index)"
			>
				<text>{{item.title}} ({{item.count}})</text>
			</view>
		</view>
		
		<view class="list">
		     <view class="list-cell" v-for="(item,index) in tabs[currentTab].list" :key="index">
		          <view class="cell-top">
					  <view>
						  <image class="headImage" :src="item.head"></image>
					  </view>
					  <view class="top-right">
						  <text class="name">{{item.nickname?item.nickname:''}}</text>
						  <!-- <text class="level">粉丝</text> -->
					  </view>
				  </view>
				  
				  <view class="cell-bottom">
					  <view class="a">
						  <text class="b">累计贡献返利</text>
						  <text class="c">¥ {{item.prize}}</text>
					  </view>
					
					  <view class="a">
						   <text class="b">推荐绑定时间</text>
					  	   <text class="c">{{item.add_time}}</text>
					  </view>
				  </view>
		     </view>
		</view>
		
	</view>
</template>

<script>
	import {
		JSMRequest
	} from '@/module/api'
	
	export default {
		data() {
			return {
				tabs_top: [
					{
						isLoadingMore: true,
						isEmpty: false,
						isLoaded: false,
						title: '我的会员',
						count:0,
					},
					{
						isLoadingMore: true,
						isEmpty: false,
						isLoaded: false,
						title: '我的粉丝',
						count:0,
					},
				],
				currentTab_top: 1,
				
				tabs: [
					{
						isLoadingMore: true,
						isEmpty: false,
						isLoaded: false,
						title: '全部',
						count:0,
						list: [],
					},
					{
						isLoadingMore: true,
						isEmpty: false,
						isLoaded: false,
						title: '直属',
						count:0,
						list: [],
					}
				],
				currentTab: 0,
				
				allData:null,
			}
		},
		
		onLoad() {
			this.getData()
		},
		
		methods: {
			getData(){
				let _t = this				
				JSMRequest({
					tag: "jsm-user-myTeam",
					method: "POST",
					params: {
						
					}
				}).then(({data}) => {
					_t.tabs_top[0].count = data.vip_num
					_t.tabs_top[1].count = data.fensi_num
					_t.tabs[0].count = data.fensi_num
					_t.tabs[1].count = data.fensi_zhitui_num
					_t.tabs[0].list = data.fensi
					_t.tabs[1].list = data.fensi_zhitui
					_t.allData = data
				}).catch(e => {
					
				})
			},
			
			onTab_topClick (index) {
				this.currentTab_top = index
				this.currentTab = 0
				if(index == 0){
					this.tabs[0].count = this.allData.vip_num
					this.tabs[1].count = this.allData.vip_zhitui_num
					this.tabs[0].list = this.allData.vip
					this.tabs[1].list = this.allData.vip_zhitui
				} else {
					this.tabs[0].count = this.allData.fensi_num
					this.tabs[1].count = this.allData.fensi_zhitui_num
					this.tabs[0].list = this.allData.fensi
					this.tabs[1].list = this.allData.fensi_zhitui
				}
			},
			
			onTabClick(index) {
				this.currentTab = index;
			},
		}
	}
</script>

<style lang="less">
.top {
	background-color: rgb(241,222,178);
	height: 120px;
}
.nav-tab_top{
        width: 90%;
        position: absolute;
        height: 80px;
        top: 20px;
        left: 5%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #fff;
		
        z-index: 10;
        .li_top{
            width: 50%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;

            text{
                color: #999;
                font-size:32px;
            }
			&.current_top{
				background-color: rgb(249,246,232);

                &::after{
                    display: block;
                    content: '';
                    position: absolute;
                    bottom: 1px;
                    left: 50%;
                    margin-left: -14px;
                    width: 38px;
                    height: 6px;
                    background: red;
                }
                
                text{
                    color: black;
                }
            }
		}
}

.nav-tab{
        width: 100%;
        position: absolute;
        height: 100px;
        top: 120px;
        left: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #fff;
		border-style: solid;
		border-width: 0 0 1px 0;
		border-color: rgb(246, 247, 248);
		
        z-index: 10;
        .li{
            width: 50%;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;

            text{
                color: #999;
                font-size:32px;
            }
			&.current{

                &::after{
                    display: block;
                    content: '';
                    position: absolute;
                    bottom: 1px;
                    left: 0;
                    width: 100%;
                    height: 6px;
                    background: red;
                }
                
                text{
                    color: red;
                }
            }
		}
}

.list {
	margin-top: 120px;
}

.list-cell {
	padding: 20px 20px 20px 20px;
	.cell-top {
		display: flex;
		flex-direction: row;
		align-items: center;
		.headImage {
			width: 88px;
			height: 88px;
			border-radius: 44px;
		}
		.top-right {
			display: flex;
			flex-direction: column;
			margin-left: 10px;
			.name {
				font-size: 24px;
			}
			.level {
				font-size: 24px;
			}
		}
	}
	
	.cell-bottom {
		margin-top: 20px;
		background-color: rgb(249, 249, 249);
		padding: 20px 30px 20px 20px;
		border-radius: 10px;
		width: 92%;
		display: flex;
		flex-direction: row;
		.a {
			width: 50%;
			display: flex;
			flex-direction: column;
		}
		.b {
			font-size: 28px;
			color: #999;
		}
		.c {
			margin-top: 10px;
			font-size: 28px;
		}
	}
}

</style>
